﻿using Cache;
using DtoFw;
using DtoFw.Base;
using DtoFw.Query;
using Microsoft.AspNetCore.Mvc;
using Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SceneEvidenceAPI.Controllers
{
    /// <summary>
    /// 编号
    /// </summary>
    [Route("api/serial")]
    public class MainNumberController : BaseController
    {
        private readonly MainNumberService _serialNumberService;
        public MainNumberController(MainNumberService serialNumberService)
        {
            this._serialNumberService = serialNumberService;
        }
        /// <summary>
        /// 新增编号
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost("post")]
        public BaseResult Post([FromBody] SerialNumberPostDto dto)
        {
            return _serialNumberService.Post(dto);
        }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPut("put")]
        public BaseResult Put([FromBody] SerialNumberPutDto dto)
        {
            return _serialNumberService.Put(dto);
        }
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpGet("query")]
        public BaseGenericResult<List<SerialNumberQueryDto>> Query(string organid)
        {
            var _user = TokenHelper.GetTokenInfo<TokenData>(User);
            return _serialNumberService.Query(_user, organid);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpDelete("delete")]
        public BaseResult Delete([FromBody] DeleteSingleDto query)
        {
            return _serialNumberService.Delete(query);
        }
    }
}
